<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>DAQ_LOG: appender.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">DAQ_LOG
   </div>
   <div id="projectbrief">logger</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">appender.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef __APPENDER_HPP_</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define __APPENDER_HPP_</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &lt;sstream&gt;</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &lt;fstream&gt;</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &lt;functional&gt;</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &lt;mutex&gt;</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &lt;czmq.h&gt;</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &lt;curl/curl.h&gt;</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &quot;loglevel.hpp&quot;</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &quot;formatter.hpp&quot;</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacedaq.html">daq</a> {</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div><div class="line"><a name="l00019"></a><span class="lineno"><a class="line" href="classdaq_1_1Appender.html">   19</a></span>&#160;<span class="keyword">class </span><a class="code" href="classdaq_1_1Appender.html">Appender</a> {</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    <span class="keyword">public</span>:</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;        <span class="keyword">using</span> sptr = std::shared_ptr&lt;Appender&gt;;</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;        <a class="code" href="classdaq_1_1Appender.html#a9b3533e893e3ece5da794fc2beab0ac7">Appender</a>() = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;        <a class="code" href="classdaq_1_1Appender.html#a9b3533e893e3ece5da794fc2beab0ac7">Appender</a>(<span class="keyword">const</span> <a class="code" href="classdaq_1_1Formatter.html">Formatter</a> formatter);</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;        <a class="code" href="classdaq_1_1Appender.html#a9b3533e893e3ece5da794fc2beab0ac7">Appender</a>(<span class="keyword">const</span> std::string&amp; formatter);</div><div class="line"><a name="l00035"></a><span class="lineno"><a class="line" href="classdaq_1_1Appender.html#ad2d27dffb18f066c342ce6f5d7c15cfb">   35</a></span>&#160;        <span class="keyword">const</span> std::string <a class="code" href="classdaq_1_1Appender.html#ad2d27dffb18f066c342ce6f5d7c15cfb">getId</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;            <span class="keywordflow">return</span> m_id;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;        }</div><div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="classdaq_1_1Appender.html#a66e8f896daf7ad4a82769949b351b994">   41</a></span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1Appender.html#a66e8f896daf7ad4a82769949b351b994">append</a>(LogEvent::sptr event) {};</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1Appender.html#a7a195556a18fb389e8bd9025a5bf9fd3">setFormatter</a>(Formatter::sptr formatter);</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classdaq_1_1Appender.html#adcc428ec459cc4534748e5184d5b597a">hasFormatter</a>();</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    <span class="keyword">public</span>:</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        <span class="keyword">virtual</span> <a class="code" href="classdaq_1_1Appender.html#abf5f9f703a7a9ea7767072dc36055ad4">~Appender</a>() = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    <span class="keyword">protected</span>:</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        std::string m_id = <span class="stringliteral">&quot;Appender&quot;</span>; </div><div class="line"><a name="l00057"></a><span class="lineno"><a class="line" href="classdaq_1_1Appender.html#a2a979f064588deb08a3b16da20174822">   57</a></span>&#160;        Formatter::sptr <a class="code" href="classdaq_1_1Appender.html#a2a979f064588deb08a3b16da20174822">m_formatter</a>;</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        std::mutex m_appendMutex;</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;};</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;</div><div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="classdaq_1_1StdoutAppender.html">   62</a></span>&#160;<span class="keyword">class </span><a class="code" href="classdaq_1_1StdoutAppender.html">StdoutAppender</a> : <span class="keyword">public</span> <a class="code" href="classdaq_1_1Appender.html">Appender</a> {</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="keyword">public</span>:</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;        <a class="code" href="classdaq_1_1StdoutAppender.html">StdoutAppender</a>();</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1Appender.html#a66e8f896daf7ad4a82769949b351b994">append</a>(LogEvent::sptr event) <span class="keyword">override</span>;</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        ~<a class="code" href="classdaq_1_1StdoutAppender.html">StdoutAppender</a>() = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;};</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;</div><div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="classdaq_1_1RollFileAppender.html">   72</a></span>&#160;<span class="keyword">class </span><a class="code" href="classdaq_1_1RollFileAppender.html">RollFileAppender</a> : <span class="keyword">public</span> <a class="code" href="classdaq_1_1Appender.html">Appender</a> {</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    <span class="keyword">public</span>:</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;        <a class="code" href="classdaq_1_1RollFileAppender.html">RollFileAppender</a>() = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;        <a class="code" href="classdaq_1_1RollFileAppender.html">RollFileAppender</a>(<span class="keyword">const</span> std::string &amp; path, u_int32_t size = 8,</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;                         <span class="keyword">const</span> std::string &amp; prefix = <span class="stringliteral">&quot;&quot;</span>, <span class="keyword">const</span> std::string &amp; subfix = <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;        ~<a class="code" href="classdaq_1_1RollFileAppender.html">RollFileAppender</a>();</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1Appender.html#a66e8f896daf7ad4a82769949b351b994">append</a>(LogEvent::sptr event) <span class="keyword">override</span>;</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;        <span class="keywordtype">void</span> createNewFile();</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;        <span class="comment">//重新打开返回true</span></div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;        <span class="keywordtype">bool</span> reopen();</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;        <span class="keywordtype">bool</span> closeFile();</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;</div><div class="line"><a name="l00102"></a><span class="lineno"><a class="line" href="classdaq_1_1RollFileAppender.html#ac58806a64d86b2b56fa778e4a3a3d667">  102</a></span>&#160;        <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1RollFileAppender.html#ac58806a64d86b2b56fa778e4a3a3d667">setPath</a>(<span class="keyword">const</span> std::string &amp; path) {</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;            m_path = path;</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;        }</div><div class="line"><a name="l00108"></a><span class="lineno"><a class="line" href="classdaq_1_1RollFileAppender.html#a21da274c5787fc3b33e972bb90762d86">  108</a></span>&#160;        <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1RollFileAppender.html#a21da274c5787fc3b33e972bb90762d86">setPrefix</a>(<span class="keyword">const</span> std::string&amp; prefix) {</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;            m_prefix = prefix;</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;        }</div><div class="line"><a name="l00114"></a><span class="lineno"><a class="line" href="classdaq_1_1RollFileAppender.html#a18c120a62efcc2e5924b7a6450171607">  114</a></span>&#160;        <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1RollFileAppender.html#a18c120a62efcc2e5924b7a6450171607">setSubfix</a>(<span class="keyword">const</span> std::string&amp; subfix) {</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;            m_subfix = subfix;</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;        }</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    <span class="keyword">private</span>:</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        std::string m_path;</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;        <span class="keywordtype">size_t</span> m_maxFileSize;       </div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;        std::string m_prefix;</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;        std::string m_subfix;</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;        std::string m_currentFileName;</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;        std::ofstream m_fileStream;</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;};</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;</div><div class="line"><a name="l00128"></a><span class="lineno"><a class="line" href="classdaq_1_1SingleFileAppender.html">  128</a></span>&#160;<span class="keyword">class </span><a class="code" href="classdaq_1_1SingleFileAppender.html">SingleFileAppender</a> : <span class="keyword">public</span> <a class="code" href="classdaq_1_1Appender.html">Appender</a> {</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <span class="keyword">public</span>:</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;        <a class="code" href="classdaq_1_1SingleFileAppender.html">SingleFileAppender</a>();</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;        <a class="code" href="classdaq_1_1SingleFileAppender.html">SingleFileAppender</a>(<span class="keyword">const</span> std::string&amp; name);</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;        ~<a class="code" href="classdaq_1_1SingleFileAppender.html">SingleFileAppender</a>();</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1Appender.html#a66e8f896daf7ad4a82769949b351b994">append</a>(LogEvent::sptr event) <span class="keyword">override</span>;</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;        <span class="keywordtype">void</span> setFileName(<span class="keyword">const</span> std::string&amp; filename) {</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;            m_fileName = filename;</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;        }</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;        <span class="keywordtype">bool</span> reopen();</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    <span class="keyword">private</span>:</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;        std::string m_fileName;</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;        std::ofstream m_fileStream;</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;};</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;<span class="comment">//ZMQ发送log,&quot;inetAddr:port&quot;</span></div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;<span class="comment">/*******************************************************************************/</span></div><div class="line"><a name="l00154"></a><span class="lineno"><a class="line" href="classdaq_1_1ZMQAppender.html">  154</a></span>&#160;<span class="keyword">class </span><a class="code" href="classdaq_1_1ZMQAppender.html">ZMQAppender</a> : <span class="keyword">public</span> <a class="code" href="classdaq_1_1Appender.html">Appender</a> {</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    <span class="keyword">public</span>:</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;        <a class="code" href="classdaq_1_1ZMQAppender.html">ZMQAppender</a>() {}</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;        <a class="code" href="classdaq_1_1ZMQAppender.html">ZMQAppender</a>(<span class="keyword">const</span> std::string&amp; host, <span class="keyword">const</span> std::string&amp; port);</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;        <a class="code" href="classdaq_1_1ZMQAppender.html">ZMQAppender</a>(<span class="keyword">const</span> std::string&amp; host, <span class="keywordtype">size_t</span> port);</div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;        <a class="code" href="classdaq_1_1ZMQAppender.html">ZMQAppender</a>(<span class="keyword">const</span> std::string&amp; endpoint);</div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;        ~<a class="code" href="classdaq_1_1ZMQAppender.html">ZMQAppender</a>();</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1Appender.html#a66e8f896daf7ad4a82769949b351b994">append</a>(LogEvent::sptr event) <span class="keyword">override</span>;</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;        <span class="keywordtype">void</span> setEndpoint(<span class="keyword">const</span> std::string&amp; endpoint) {</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;            m_endpoint = endpoint;</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;        }</div><div class="line"><a name="l00177"></a><span class="lineno"><a class="line" href="classdaq_1_1ZMQAppender.html#a0d330bf4e03d7cce1f13e1be1fdf5581">  177</a></span>&#160;        <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1ZMQAppender.html#a0d330bf4e03d7cce1f13e1be1fdf5581">setEndpoint</a>(<span class="keyword">const</span> std::string&amp; host, <span class="keywordtype">size_t</span> port) {</div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;            m_host = host;</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;            m_port = std::to_string(port);</div><div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;            m_endpoint = <span class="stringliteral">&quot;tcp://&quot;</span> + m_host + <span class="stringliteral">&quot;:&quot;</span> + m_port;</div><div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;        }</div><div class="line"><a name="l00186"></a><span class="lineno"><a class="line" href="classdaq_1_1ZMQAppender.html#a04132ad59cf83f8555f6fb6a4f8993d6">  186</a></span>&#160;        <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1ZMQAppender.html#a04132ad59cf83f8555f6fb6a4f8993d6">setEndpoint</a>(<span class="keyword">const</span> std::string&amp; host, <span class="keyword">const</span> std::string&amp; port) {</div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;            m_host = host;</div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;            m_port = port;</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;            m_endpoint = <span class="stringliteral">&quot;tcp://&quot;</span> + m_host + <span class="stringliteral">&quot;:&quot;</span> + m_port;</div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;        }</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;</div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;    <span class="keyword">private</span>:</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;        zsock_t *m_push;</div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;        std::string m_host;</div><div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;        std::string m_port;</div><div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;        std::string m_endpoint;</div><div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;        std::ofstream m_fileStream;</div><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;};</div><div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;</div><div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;<span class="comment">//HTTP发送JSON</span></div><div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;<span class="comment">/*******************************************************************************/</span></div><div class="line"><a name="l00202"></a><span class="lineno"><a class="line" href="classdaq_1_1HTTPAppender.html">  202</a></span>&#160;<span class="keyword">class </span><a class="code" href="classdaq_1_1HTTPAppender.html">HTTPAppender</a> : <span class="keyword">public</span> <a class="code" href="classdaq_1_1Appender.html">Appender</a> {</div><div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;    <span class="keyword">public</span>:</div><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;        <a class="code" href="classdaq_1_1HTTPAppender.html">HTTPAppender</a>(<span class="keyword">const</span> std::string&amp; host, <span class="keyword">const</span> std::string&amp; port);</div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;        <a class="code" href="classdaq_1_1HTTPAppender.html">HTTPAppender</a>(<span class="keyword">const</span> std::string&amp; host, <span class="keywordtype">size_t</span> port);</div><div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;        ~<a class="code" href="classdaq_1_1HTTPAppender.html">HTTPAppender</a>();</div><div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;</div><div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classdaq_1_1Appender.html#a66e8f896daf7ad4a82769949b351b994">append</a>(LogEvent::sptr event) <span class="keyword">override</span>;</div><div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;</div><div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;    <span class="keyword">private</span>:</div><div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;        <span class="keywordtype">int</span> init();</div><div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;</div><div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;    <span class="keyword">private</span>:</div><div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;        std::string m_host;</div><div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;        <span class="keywordtype">long</span> m_port;</div><div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;</div><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;        CURL *pCurl = NULL;</div><div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;        std::string m_url;</div><div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;</div><div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;        <span class="keyword">struct </span>curl_slist *headerlist = NULL;</div><div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;        <span class="keyword">struct </span>curl_httppost *post = NULL;</div><div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;        <span class="keyword">struct </span>curl_httppost *last = NULL;</div><div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;};</div><div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;</div><div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;} <span class="comment">//DAQ</span></div><div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/*__APPENDER_HPP_*/</span><span class="preprocessor"></span></div><div class="ttc" id="classdaq_1_1StdoutAppender_html"><div class="ttname"><a href="classdaq_1_1StdoutAppender.html">daq::StdoutAppender</a></div><div class="ttdoc">StdoutAppender输出到控制台 </div><div class="ttdef"><b>Definition:</b> appender.hpp:62</div></div>
<div class="ttc" id="classdaq_1_1RollFileAppender_html_a18c120a62efcc2e5924b7a6450171607"><div class="ttname"><a href="classdaq_1_1RollFileAppender.html#a18c120a62efcc2e5924b7a6450171607">daq::RollFileAppender::setSubfix</a></div><div class="ttdeci">void setSubfix(const std::string &amp;subfix)</div><div class="ttdoc">设置后缀 </div><div class="ttdef"><b>Definition:</b> appender.hpp:114</div></div>
<div class="ttc" id="classdaq_1_1Appender_html_a9b3533e893e3ece5da794fc2beab0ac7"><div class="ttname"><a href="classdaq_1_1Appender.html#a9b3533e893e3ece5da794fc2beab0ac7">daq::Appender::Appender</a></div><div class="ttdeci">Appender()=default</div><div class="ttdoc">Appender 默认构造函数 </div></div>
<div class="ttc" id="classdaq_1_1Formatter_html"><div class="ttname"><a href="classdaq_1_1Formatter.html">daq::Formatter</a></div><div class="ttdef"><b>Definition:</b> formatter.hpp:14</div></div>
<div class="ttc" id="classdaq_1_1Appender_html"><div class="ttname"><a href="classdaq_1_1Appender.html">daq::Appender</a></div><div class="ttdoc">输出器的虚基类 </div><div class="ttdef"><b>Definition:</b> appender.hpp:19</div></div>
<div class="ttc" id="classdaq_1_1RollFileAppender_html_ac58806a64d86b2b56fa778e4a3a3d667"><div class="ttname"><a href="classdaq_1_1RollFileAppender.html#ac58806a64d86b2b56fa778e4a3a3d667">daq::RollFileAppender::setPath</a></div><div class="ttdeci">void setPath(const std::string &amp;path)</div><div class="ttdoc">设置输出目录 </div><div class="ttdef"><b>Definition:</b> appender.hpp:102</div></div>
<div class="ttc" id="classdaq_1_1RollFileAppender_html_a21da274c5787fc3b33e972bb90762d86"><div class="ttname"><a href="classdaq_1_1RollFileAppender.html#a21da274c5787fc3b33e972bb90762d86">daq::RollFileAppender::setPrefix</a></div><div class="ttdeci">void setPrefix(const std::string &amp;prefix)</div><div class="ttdoc">设置前缀 </div><div class="ttdef"><b>Definition:</b> appender.hpp:108</div></div>
<div class="ttc" id="namespacedaq_html"><div class="ttname"><a href="namespacedaq.html">daq</a></div><div class="ttdef"><b>Definition:</b> appender.hpp:16</div></div>
<div class="ttc" id="classdaq_1_1SingleFileAppender_html"><div class="ttname"><a href="classdaq_1_1SingleFileAppender.html">daq::SingleFileAppender</a></div><div class="ttdoc">输出到指定文件 </div><div class="ttdef"><b>Definition:</b> appender.hpp:128</div></div>
<div class="ttc" id="classdaq_1_1Appender_html_ad2d27dffb18f066c342ce6f5d7c15cfb"><div class="ttname"><a href="classdaq_1_1Appender.html#ad2d27dffb18f066c342ce6f5d7c15cfb">daq::Appender::getId</a></div><div class="ttdeci">const std::string getId() const</div><div class="ttdoc">getId 得到Appender的id 避免相同LogAppender加入到Logger，使得重复输出 </div><div class="ttdef"><b>Definition:</b> appender.hpp:35</div></div>
<div class="ttc" id="classdaq_1_1Appender_html_abf5f9f703a7a9ea7767072dc36055ad4"><div class="ttname"><a href="classdaq_1_1Appender.html#abf5f9f703a7a9ea7767072dc36055ad4">daq::Appender::~Appender</a></div><div class="ttdeci">virtual ~Appender()=default</div><div class="ttdoc">析构函数 </div></div>
<div class="ttc" id="classdaq_1_1ZMQAppender_html_a0d330bf4e03d7cce1f13e1be1fdf5581"><div class="ttname"><a href="classdaq_1_1ZMQAppender.html#a0d330bf4e03d7cce1f13e1be1fdf5581">daq::ZMQAppender::setEndpoint</a></div><div class="ttdeci">void setEndpoint(const std::string &amp;host, size_t port)</div><div class="ttdoc">setEndpoint 设置接收端地址 </div><div class="ttdef"><b>Definition:</b> appender.hpp:177</div></div>
<div class="ttc" id="classdaq_1_1Appender_html_a7a195556a18fb389e8bd9025a5bf9fd3"><div class="ttname"><a href="classdaq_1_1Appender.html#a7a195556a18fb389e8bd9025a5bf9fd3">daq::Appender::setFormatter</a></div><div class="ttdeci">virtual void setFormatter(Formatter::sptr formatter)</div><div class="ttdoc">设置输出格式 </div></div>
<div class="ttc" id="classdaq_1_1ZMQAppender_html"><div class="ttname"><a href="classdaq_1_1ZMQAppender.html">daq::ZMQAppender</a></div><div class="ttdoc">使用管道模式发送log的ZMQAppender </div><div class="ttdef"><b>Definition:</b> appender.hpp:154</div></div>
<div class="ttc" id="classdaq_1_1HTTPAppender_html"><div class="ttname"><a href="classdaq_1_1HTTPAppender.html">daq::HTTPAppender</a></div><div class="ttdef"><b>Definition:</b> appender.hpp:202</div></div>
<div class="ttc" id="classdaq_1_1RollFileAppender_html"><div class="ttname"><a href="classdaq_1_1RollFileAppender.html">daq::RollFileAppender</a></div><div class="ttdoc">滚动输出到文件 </div><div class="ttdef"><b>Definition:</b> appender.hpp:72</div></div>
<div class="ttc" id="classdaq_1_1Appender_html_a2a979f064588deb08a3b16da20174822"><div class="ttname"><a href="classdaq_1_1Appender.html#a2a979f064588deb08a3b16da20174822">daq::Appender::m_formatter</a></div><div class="ttdeci">Formatter::sptr m_formatter</div><div class="ttdoc">避免相同LogAppender加入到Logger，使得重复输出 </div><div class="ttdef"><b>Definition:</b> appender.hpp:57</div></div>
<div class="ttc" id="classdaq_1_1ZMQAppender_html_a04132ad59cf83f8555f6fb6a4f8993d6"><div class="ttname"><a href="classdaq_1_1ZMQAppender.html#a04132ad59cf83f8555f6fb6a4f8993d6">daq::ZMQAppender::setEndpoint</a></div><div class="ttdeci">void setEndpoint(const std::string &amp;host, const std::string &amp;port)</div><div class="ttdoc">setEndpoint 设置接收端地址 </div><div class="ttdef"><b>Definition:</b> appender.hpp:186</div></div>
<div class="ttc" id="classdaq_1_1Appender_html_a66e8f896daf7ad4a82769949b351b994"><div class="ttname"><a href="classdaq_1_1Appender.html#a66e8f896daf7ad4a82769949b351b994">daq::Appender::append</a></div><div class="ttdeci">virtual void append(LogEvent::sptr event)</div><div class="ttdoc">日志输出函数 </div><div class="ttdef"><b>Definition:</b> appender.hpp:41</div></div>
<div class="ttc" id="classdaq_1_1Appender_html_adcc428ec459cc4534748e5184d5b597a"><div class="ttname"><a href="classdaq_1_1Appender.html#adcc428ec459cc4534748e5184d5b597a">daq::Appender::hasFormatter</a></div><div class="ttdeci">virtual bool hasFormatter()</div><div class="ttdoc">判断是否已经有了Formatter </div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
